package com.xiang.sql.mapper;

import com.xiang.sql.entity.User;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * 用户 Mapper 接口
 * 
 * @author mac-xiang
 */
public interface UserMapper extends BaseMapper<User> {
  @Select({
      "SELECT pid FROM `user` WHERE id='${id}'"
  })
  String getPidById(@Param("id") String id);

  @Select({
      "SELECT u2.* FROM `user` u1 JOIN `user` u2 ON u1.pid=u2.id WHERE u1.id='${id}';"
  })
  User getParentById(@Param("id") String id);
}
